package com.magiccompass.alipay.barcode.service;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.magiccompass.alipay.barcode.entity.ProductInfo;

@Service("merchantProductInputService")
@Transactional
public class MerchantProductInputServiceImpl implements MerchantProductInputService {
	@Resource(name="sessionFactory")
	private SessionFactory sessionFactory;
	 
    public MerchantProductInputServiceImpl() {
    }
    
	@Override
	public List<ProductInfo> listAllProducts(){
		Session session = sessionFactory.getCurrentSession();
		Criteria criteria = session.createCriteria(ProductInfo.class);
		List<ProductInfo> allProductsList = criteria.list();
		return allProductsList;
	}
	
	@Override
	public ProductInfo findProductById(Integer id){
		Session session = sessionFactory.getCurrentSession();
		return (ProductInfo)session.get(ProductInfo.class, id);
	}
}